# -*- coding: utf-8 -*-
# https://pythonhosted.org/gearman/client.html#extending-the-client

from gearman import GearmanWorker
from function import get_config

server = get_config('Gearman_Job_Server', 'host')
worker = GearmanWorker([server])

def task_listener_reverse(worker, job):
    print 'Reversing string: ' + job.data
    return job.data[::-1]

worker.set_client_id('python-worker')
worker.register_task('reverse', task_listener_reverse)

worker.work()